package com.itheima.sc.impl.cms;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.sc.api.cms.PrefrenceAreaProductRelationApi;
import com.itheima.sc.mapper.cms.PrefrenceAreaProductRelationMapper;
import com.itheima.sc.pojo.cms.PrefrenceAreaProductRelation;
import org.apache.dubbo.config.annotation.DubboService;

import java.util.List;

@DubboService
public class PrefrenceAreaProductRelationImpl extends ServiceImpl<PrefrenceAreaProductRelationMapper, PrefrenceAreaProductRelation> implements PrefrenceAreaProductRelationApi {
    @Override
    public List<PrefrenceAreaProductRelation> getByPid(Integer pid) {
        LambdaQueryWrapper<PrefrenceAreaProductRelation> wrapper = new LambdaQueryWrapper<PrefrenceAreaProductRelation>().eq(PrefrenceAreaProductRelation::getProductId, pid);
        return list(wrapper);
    }

    @Override
    public void removeByPid(Integer pid) {
        LambdaQueryWrapper<PrefrenceAreaProductRelation> wrapper = new LambdaQueryWrapper<PrefrenceAreaProductRelation>().eq(PrefrenceAreaProductRelation::getProductId, pid);
        remove(wrapper);

    }
}
